package com.presalept.iosappapi;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.presalept.manipulatedata.RetrieveData;


/**
 * Servlet implementation class iosappmainpage
 */
@WebServlet("/iosappmainpage")
public class iosappmainpage extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public iosappmainpage() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		response.setCharacterEncoding("UTF-8");
		
		request.setCharacterEncoding("UTF-8");
		
		response.setContentType("text/html");
		
		PrintWriter out = response.getWriter();
		
		out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
		out.println("<HTML>");
		out.println("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");
		out.println("<HEAD><TITLE>A Servlet</TITLE></HEAD>");
		out.println("<BODY>");
		
		String Userid = request.getParameter("userid");
		
		
		try {
				RetrieveData rdata = new RetrieveData();
				
				
				String strResult = rdata.GetPersonalMainPageAll(Integer.parseInt(Userid));
				
				out.println(strResult);
						
		} catch (Exception e) {
			// TODO Auto-generated catch block
			out.println("\n" + e.getMessage());
			
		}	
		out.println("</BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setCharacterEncoding("UTF-8");
		
		request.setCharacterEncoding("UTF-8");
		
		response.setContentType("text/html");
		
		PrintWriter out = response.getWriter();
		
		out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
		out.println("<HTML>");
		out.println("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");
		out.println("<HEAD><TITLE>A Servlet</TITLE></HEAD>");
		out.println("<BODY>");
		
		String Userid = request.getParameter("usrid");
		
		try {
				RetrieveData rdata = new RetrieveData();
				
				
				String strResult = rdata.GetPersonalMainPageAll(Integer.parseInt(Userid));
				
				out.println(strResult);
						
		} catch (Exception e) {
			// TODO Auto-generated catch block
			out.println("\n" + e.getMessage());
			
		}	
		out.println("</BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
	}

}
